<template>
<div>
  <!-- 面包屑导航条 -->
  <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/toOneList' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>借贷管理</el-breadcrumb-item>
    <el-breadcrumb-item>借款审核</el-breadcrumb-item>
  </el-breadcrumb>
<!--  内容卡片-->
  <el-card>
    <el-input style="width: 200px" v-model="obj.borrowerId" placeholder="借款人id"></el-input>
    <el-button type="primary" @click="sel01()">查询</el-button>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        align="center"
        type="index"
        label="序号">
      </el-table-column>
      <el-table-column
        align="center"
        prop="bidName"
        label="标名">
      </el-table-column>
      <el-table-column
        align="center"
        prop="fullName"
        label="借款人姓名">
      </el-table-column>
      <el-table-column
        align="center"
        prop="riskLev"
        label="风险等级">
        <template slot-scope="scope">
          {{scope.row.riskLev|riskLevfilt}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="totalAmount"
        label="借款总金额">
      </el-table-column>
      <el-table-column
        align="center"
        prop="interest"
        label="年利率">
        <template slot-scope="scope">
          {{scope.row.interest}}%
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="repayType"
        label="还款方式(0:一次性还款 1:等额本金 2:等额本息)">
        <template slot-scope="scope">
          {{scope.row.repayType|repayTypefilt}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="termType"
        label="期限类型（0：月 1：天）">
        <template slot-scope="scope">
          {{scope.row.termType=="0"?"月":"天"}}
        </template>
      </el-table-column>

      <el-table-column
        align="center"
        prop="trem"
        label="借款期限">
        <template slot-scope="scope">
          {{scope.row.trem}}
          {{scope.row.termType=="0"?"天":"月"}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="manageRate"
        label="管理费月率(每个月收的手续费百分比)">
        <template slot-scope="scope">
          {{scope.row.manageRate}}%
        </template>
      </el-table-column>

      <el-table-column
        align="center"
        prop="fineRate"
        label="超期不还罚款的利息">
        <template slot-scope="scope">
          {{scope.row.fineRate}}%
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="loanType"
        label="借款类型（0：新增 1：续贷 2：资产处理）">
        <template slot-scope="scope">
          {{scope.row.loanType|loanTypefilt}}
        </template>
      </el-table-column>

      <el-table-column
        align="center"
        prop="useFund"
        label="资金用途">
      </el-table-column>
      <el-table-column
        align="center"
        prop="repaySouce"
        label="还款来源">
      </el-table-column>
      <el-table-column
        align="center"
        prop="status"
        label="状态【未提交，审核中，通过，驳回，流标，撤标，满标，放款">
        <template slot-scope="scope">
          {{scope.row.status | stsfilt}}
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="createTime"
        label="创建时间">
        <template slot-scope="scope">
          {{scope.row.createTime | datefmt('YYYY-MM-DD HH:mm:ss')}}
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--        prop="updateTime"-->
<!--        label="修改时间">-->
<!--        <template slot-scope="scope">-->
<!--          {{scope.row.updateTime | datefmt('YYYY-MM-DD HH:mm:ss')}}-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        prop="approver"-->
<!--        label="审核人id">-->
<!--      </el-table-column>-->
      <el-table-column
        align="center"
        label="操作">
        <template slot-scope="scope">
          <el-dropdown size="mini" split-button type="primary" trigger="click">
            操作
            <el-dropdown-menu slot="dropdown">
<!--              <el-dropdown-item @click.native="updatestate(scope.row.id,1)" v-if="scope.row.status==0">提交</el-dropdown-item>-->
              <el-dropdown-item @click.native="updatestatus(scope.row.id,2)" v-if="scope.row.status==1">通过</el-dropdown-item>
              <el-dropdown-item @click.native="updatestate(scope.row.id,3)" v-if="scope.row.status==1">不通过</el-dropdown-item>
              <!--<el-dropdown-item @click.native="updatestate(scope.row.id,2)" v-if="scope.row.status==1">通过</el-dropdown-item>
              <el-dropdown-item @click.native="updatestate(scope.row.id,3)" v-if="scope.row.status==1">不通过</el-dropdown-item>-->
              <el-dropdown-item @click.native="updatestate(scope.row.id)" v-if="scope.row.status==1">审核</el-dropdown-item>
              <el-dropdown-item @click.native="toaddbiao(scope.row.id)" v-if="scope.row.status==2">标的添加</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>

    </el-table>
    <el-pagination
      align="center"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.pagenum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="page.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </el-card>
<!--  {{tableData}}-->
</div>
</template>

<script>
  export default {
    name: 'borrowcheck',
    data(){
      return{
        obj:{},
        tableData:[],//借款信息集合
        total:0,
        page:{
          pagenum:0,
          pagesize:5
        }
      }
    },
    methods:{
      toaddbiao:function(id){
        // this.updatestate(id,4);
        this.$router.push("/addbiao?id="+id);

      },
      updatestate:function(id,val){ //审核状态修改
        this.$router.push("/shenhe?id="+id);
      },
      updatestatus:function(){
        this.$http.post("/finance-service-borrowing/loan/updatestate/"+id+"/"+val).then((res)=>{
            if(res.data.success){
              this.$message({
                type: 'success',
                message: res.data.message
              });
              this.sel01();
            }else {
              this.$message({
                type: 'error',
                message: res.data.message
              });
            }
          }
        )
      },
      handleSizeChange:function (val) {
        this.page.pagesize=val;
        this.sel01();
      },
      handleCurrentChange:function (val) {
        this.page.pagenum=val;
        this.sel01();
      },
      sel01:function () {//查询借款信息集合
        this.$http.post("/finance-service-borrowing/loan/list/"+this.page.pagenum+"/"+this.page.pagesize,this.obj).then(
          (res)=>{
            debugger
            this.tableData=res.data.result.list;
            this.total=res.data.result.total;
          }
        )
      }

    },
    mounted () {
      this.sel01();
    },
    filters:{
      loanTypefilt:function(val){//借款类型
        if(val==0){
          return"新增"
        }
        if(val==1){
          return"续贷"
        }
        if(val==2){
          return"资产处理"
        }

      },
      repayTypefilt:function(val){//还款方式
        if(val==0){
          return"一次性还款"
        }
        if(val==1){
          return"等额本金"
        }
        if(val==2){
          return"等额本息"
        }
      },
      riskLevfilt:function(val){
        if(val==0){
          return "极低"
        }
        if(val==1){
          return "较低"
        }
        if(val==2){
          return "中等"
        }
        if(val==3){
          return "中高"
        }
        if(val==4){
          return "高"
        }
      },
      stsfilt:function (val) {//状态过滤
        if(val==0){
          return "草稿"
        }
        if(val==1){
          return "待审核"
        }
        if(val==2){
          return "已经审核"
        }
        if(val==3){
          return "审核未通过"
        }
        if(val==4){
          return "未发标"
        }
        if(val==5){
          return "已发标"
        }
        if(val==6){
          return "募集中"
        }
        if(val==7){
          return "标满复审"
        }
        if(val==8){
          return "已放款"
        }

      }
    }
  }
</script>

<style scoped>

</style>
